// pages/distribut/share/share.js
//获取应用实例
var app = getApp();
var request = app.request;
var setting = app.globalData.setting;
var bmap = require('../../../libs/bmap-wx.min.js');
var util = require('../../../utils/util.js');
var common = require('../../../utils/common.js');
var WxParse = require('../../../utils/wxParse/wxParse.js');
import LoadMore from '../../../utils/LoadMore.js';
var load = new LoadMore;
import Regions from '../../../utils/regions/Regions.js';

Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		statusBar: app.globalData.statusBar,
		customBar: app.globalData.customBar,
		custom: app.globalData.custom,
		url: setting.url,
		page: 6,
		pickup_address: '',
		userInfo: app.globalData.userInfo,
	},
	topages: function(e) {
		var idx = e.currentTarget.dataset.idx;
		app.globalData.menu_index = idx;
		common.defaultTotabar(idx, 7);
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {

	},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {
		console.log('请问是')
		let that=this
		   setTimeout(function() {
		        that.shop_select()
		      }, 1000)
		
		// var address2 = wx.getStorageSync('shop_select');
		// if (address2) {
		// 	this.setData({
		// 		pickup_address: address2
		// 	})
		// }
	},
	// 获取当前定位自提点
	shop_select(){
	  var that = this;
	  request.get(that.data.url + '/api/user/shop_select', {
	    success: function (res) {
			console.log(res)
	        that.setData({ pickup_address: res.data.result});
	    }
	  });
	},
	clickMenu(e) {
		var that = this;
		// if (that.data.click) return false;
		// that.data.click = true;
		//在个人中心浏览其他入口页面前判断是否登录
		if (!that.data.userInfo) {
			app.getUserInfo(function(userInfo) {
				that.setData({
					userInfo: userInfo,
					click: false
				});
			}, true, false);
			return false;
		}
		if (e.currentTarget.dataset.url == '/pages/distribut/index/index') {
			if (that.data.distribut == 0) {
				// that.data.click = false;
				return app.showTextWarining('分销功能已关闭')
			}
		}
		if (e.currentTarget.dataset.url == '/pages/user/sign_in/sign_in') {
			if (that.data.sign == 0) {
				// that.data.click = false;
				return app.showTextWarining('签到功能已关闭')
			}
		}
		if (e.currentTarget.dataset.url == 'webview') {
			this.setData({
				webUrl: "/Mobile/User/userHelpList/app/3"
			});
			wx.navigateTo({
				url: '/pages/index/webview/webview'
			});
			return false;
		}

		wx.navigateTo({
			url: e.currentTarget.dataset.url
		});
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},



	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})